diff options
| author | real-zephex <[email protected]> | 2024-03-17 07:08:55 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-03-17 07:08:55 +0530 |
| commit | bc2963f9e76a4000e3f1747b6fa4affdebba3956 (patch) | |
| tree | 39fa19bbe792b3b90b526ef5460545c76bca3dcf /src/app/video/[animeId] | |
| parent | minor fixes and feature improvements: added an indicator which shows when the... (diff) | |
| download | dramalama-bc2963f9e76a4000e3f1747b6fa4affdebba3956.tar.xz dramalama-bc2963f9e76a4000e3f1747b6fa4affdebba3956.zip | |
prettified the code :)
Diffstat (limited to 'src/app/video/[animeId]')
| -rw-r--r-- | src/app/video/[animeId]/page.js | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/src/app/video/[animeId]/page.js b/src/app/video/[animeId]/page.js index af7e690..4cd74ce 100644 --- a/src/app/video/[animeId]/page.js +++ b/src/app/video/[animeId]/page.js @@ -1,51 +1,61 @@ -"use client" +"use client"; -import '../video.css' -import React, { useState, useEffect } from 'react'; -import ReactPlayer from 'react-player'; +import "../video.css"; +import React, { useState, useEffect } from "react"; +import ReactPlayer from "react-player"; export default function Video({ params }) { - const id = params.animeId; - const [videoLink, setVideoLink] = useState(null); - const [loading, setLoading] = useState(true); + const id = params.animeId; + const [videoLink, setVideoLink] = useState(null); + const [loading, setLoading] = useState(true); const [epi, setEpi] = useState(""); - - useEffect(() => { - fetch("https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id) - .then(res => res.json()) - .then(data => { - const words = id.split("-") + useEffect(() => { + fetch("https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id) + .then((res) => res.json()) + .then((data) => { + const words = id.split("-"); const last_two = words.slice(-2).join(" "); const remainingWords = words.slice(0, -2).join(" "); - setEpi([last_two, remainingWords]) - setVideoLink(data.sources[3].url); - setLoading(false); - }) - .catch(error => { - console.log("Some error occured", error); - setLoading(false); - }); - }, [id]); + setEpi([last_two, remainingWords]); + setVideoLink(data.sources[3].url); + setLoading(false); + }) + .catch((error) => { + console.log("Some error occured", error); + setLoading(false); + }); + }, [id]); - return ( - <div> - {loading && ( - <p style={{color: "white", fontFamily: "Lato", fontSize: "20px", textAlign: "center"}}>Loading...</p> - )} + return ( + <div> + {loading && ( + <p + style={{ + color: "white", + fontFamily: "Lato", + fontSize: "20px", + textAlign: "center", + }} + > + Loading... + </p> + )} {videoLink && ( - <div className='video2'> - <p>{epi[0]} - {epi[1]}</p> - <ReactPlayer - className='react-player' + <div className="video2"> + <p> + {epi[0]} - {epi[1]} + </p> + <ReactPlayer + className="react-player" url={videoLink} controls autoplay width="95%" - height="95%" + height="95%" /> </div> )} - </div> - ); + </div> + ); } |